/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package pasta;

import java.io.FileOutputStream;
import java.util.Iterator;
import java.util.Vector;

/**
 *
 * @author Junior
 */
public class Merger {

    Merger (String fileName, Vector<byte[]> bytes, String storageDirectory) {

        try {

            Iterator byteItr = bytes.iterator();
            FileOutputStream outputFile = new FileOutputStream(storageDirectory + "/" + fileName);

            while (byteItr.hasNext()) {

                byte [] inputByte = (byte[]) byteItr.next();

                int c = 0;

                while(c < inputByte.length) {
                    outputFile.write ((int)inputByte[c++]);
                }

            }
            outputFile.close();

        } catch(Exception e) {
            System.out.println("Merge Error");
            e.printStackTrace();
        }
    }
}